﻿Imports EHaskins.Frc.Dashboard

Module Module1

    Sub Main()
        Dim dashboard As New DashboardClient(Of DefaultUserDataProcessor)
        dashboard.BeginUpdating()

        Dim lastIndex As Integer
        Dim printedLength As Integer
        Dim errorLength As Integer

        Do
            Dim data = dashboard.UserData
            If data IsNot Nothing AndAlso _
                Not lastIndex = data.PacketNumber Then

                'Write new printed strings
                If data.PrintedStrings.Count > printedLength Then
                    For i = printedLength To data.PrintedStrings.Count() - 1
                        Console.WriteLine(data.PrintedStrings(i))
                    Next
                    printedLength = data.PrintedStrings.Count()
                End If

                'Write new error strings
                If data.ErrorStrings.Count > errorLength Then
                    For i = errorLength To data.ErrorStrings.Count() - 1
                        Dim oldColor = Console.ForegroundColor
                        Console.ForegroundColor = ConsoleColor.Red

                        Console.WriteLine(data.ErrorStrings(i))

                        Console.ForegroundColor = oldColor
                    Next
                    errorLength = data.ErrorStrings.Count()
                End If
            End If

            Threading.Thread.Sleep(10) 'Give the CPU a break. :)
        Loop

    End Sub

End Module
